# 1.单线程
# 【2.多线程】
# 3.资源共享与竞争

import time
from threading import Thread, Lock, current_thread


def funa():
    print(f'开始{current_thread().name}')
    time.sleep(5)
    print(f'结束{current_thread().name}')

def funb():
    print(f'开始{current_thread().name}')
    time.sleep(7)
    print(f'结束{current_thread().name}')

# 设置守护线程 当守护线程结束 其他线程也结束
if __name__ == '__main__' :
    ta = Thread(target=funa)
    tb = Thread(target=funb)
    tb.name = '线程1'
    tb.daemon = True
    tb.start()
    ta.name = '线程2'
    ta.daemon = True
    ta.start()
    time.sleep(10)
    print('守护线程结束')













